<template>
	<view class="body-view">
		<!--导航和状态栏-->
		<view class="state-navigation">
			<view class="slim_header_navigation d-flex a-center j-center" >
				<view class="left_box" @tap="goBack">
					<image src="/static/center/back.png" class="back"></image>
				</view>
				<view class="title">身体数据</view>
				<!-- <view class="right_box" @tap="openSt">
                    <view class="st_btn" v-if="VER.ver">声明与文献</view>
                </view> -->
			</view>
		</view>
		<!-- 顶部位置占位 -->
		<view style="height:calc(120rpx + var(--status-bar-height));"></view>
		<scroll-view scroll-y="true" style="height:calc(100vh - 120rpx - var(--status-bar-height));">
			<view class="data-view" style="padding-top: 0;">
				<view class="data-info">
					<view class="data-info-title d-flex a-center">
						<view class="info-title-background"></view>
						<view class="info-title-text">数据信息</view>
					</view>
					<!--身高和年龄-->
					<view class="data-info-content d-flex j-between">
						<view @tap="showBirthdayPopup" class="content-piece d-flex a-center j-center">
							<view class="piece-title piece-age">年龄</view>
							<text class="piece-title-number">{{bodyInfo?.userHealth?.age}}</text>
							<text class="piece-title-unit">岁</text>
						</view>
						<view @tap="showHeightPopup" class="content-piece d-flex a-center j-center">
							<view class="piece-title piece-height">身高</view>
							<text class="piece-title-number">{{bodyInfo?.userHealth?.stature}}</text>
							<text class="piece-title-unit">cm</text>
						</view>
					</view>
					<!--体重信息-->
					<view class="data-info-content" style="padding-top:20rpx">
						<view class="content-piece-weight">
							<view class="piece-title piece-weight">体重</view>
							<view class="d-flex d-c a-center j-center">
								<view class="piece-describe">当前体重</view>
								<view @tap="showWeightRecord" class="piece-current">
									<text class="piece-current-number">{{bodyInfo?.userWeightRecord?.weight}}</text>
									<text class="piece-current-unit">KG</text>
								</view>
							</view>
							<view class="weight-row-below d-flex a-center j-between">
								<view @tap="showEditIntiWeight" class="row-below-title">
									<view class="below-title-text">初始</view>
									<view class="below-title-value">
										<text class="title-value-number">{{bodyInfo?.userHealth?.initWeight}}</text>
										<text class="title-value-unit">KG</text>
									</view>
								</view>
								<view class="row-below-progress">
									<view class="progress-bottom">
										
										<view class="progress-complete" :style="{ width : schedule + '%' }"></view>
										<view class="progress-indicate" :style="{ left : schedule + '%' }">
											<view v-if="schedule>50" class="progress-indicate-reduce" style="left: -190rpx;text-align: right;">已减{{complete}}kg</view>
											<view v-else class="progress-indicate-reduce" style="right:-190rpx;">已减{{complete}}kg</view>
											<view class="progress-indicate-number">{{schedule}}%</view>
											<image style="width: 100%;height: 100%;" src="/static/image/record-slider.png" ></image>
										</view>
									</view>
								</view>
								<view @tap="showEditAimWeight" class="row-below-title">
									<view class="below-title-text">目标</view>
									<view class="below-title-value">
										<text class="title-value-number">{{bodyInfo?.userHealth?.aimWeight}}</text>
										<text class="title-value-unit">KG</text>
									</view>
								</view>
							</view>
						</view>
					</view>
					<!--热量差-->
					<view @tap="showCaloriePopup" class="data-info-content" style="padding-top:20rpx;height: 220rpx;" >
						<view class="flicker-background" :class="{active:active}"></view>
						<view class="content-piece-margin d-flex" >
							<view class="piece-title piece-weight">热量差</view>
							<view class="piece-margin-left d-flex a-center j-center">
								<view class="margin-left-number">{{bodyInfo?.userHealth?.heatIsPoor}}</view>
								<view class="margin-left-unit">千卡</view>
							</view>
							<view class="piece-margin-right">
								<view class="margin-right-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;设置合适的热量差，让您健康的瘦下来；{{describe}}</view>
							</view>
						</view>
					</view>
					<!--指标-->
					<view class="data-info-content" style="padding-top:20rpx">
						<view @tap="goBodyDataDetails" class="content-piece-index d-flex j-center" :class="`${isNormal?'index-normal':'index-overrun'}`">
							<view class="piece-title" :class="`${isNormal?'title-normal':'title-overrun'}`">指标</view>
							<view class="piece-more d-flex a-center j-center" :class="`${isNormal?'more-normal':'more-overrun'}`">
								<image style="width: 20rpx;height: 20rpx;" src="@/static/image/icon-more.png"></image>
							</view>
							
							<view class="piece-index-content d-flex j-center">
								<view class="index-content-piece">
									
									<view class="index-info">
										<view class="index-info-mark" :class="`${isNormal?'title-normal':'title-overrun'}`">{{BMITip(BMI)}}</view>
										<text class="index-info-number">{{BMI}}</text>
									</view>
									<view class="index-info-title">BMI</view>
								</view>
							</view>
							<view class="piece-index-content d-flex j-center">
								<view class="index-content-piece">
									<div class="d-flex a-center j-center">
										<view class="index-info d-flex a-center j-center">
											<view class="index-info-mark" :class="`${isNormal?'title-normal':'title-overrun'}`">{{bodyfatTip(bodyfat)}}</view>
											<text class="index-info-number">{{bodyfat}}</text>
											<text class="index-info-unit">%</text>
										</view>
									</div>
									<view class="index-info-title">预估体脂率</view>
								</view>
							</view>
							<view class="piece-index-content d-flex j-center">
								<view class="index-content-piece">
									<view class="index-info  d-flex a-center j-center">
										<text class="index-info-number">{{consumeRest}}</text>
										<text class="index-info-unit">千卡</text>
									</view>
									<view class="index-info-title">基础代谢</view>
								</view>
							</view>
						</view>
					</view>
				</view>
				
				<view class="data-info" style="margin-top: 20rpx;">
					<view class="data-info-title d-flex a-center">
						<view class="info-title-background" style="width: 238rpx;"></view>
						<view class="info-title-text">饮食和运动建议</view>
					</view>
					<view class="data-info-advice">饮食建议</view>
					<!--严重超重-->
					<template v-if="BMITip(BMI)=='严重超重'">
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;建议饮食摄入上不要有[过大]的热量差，以免出于难以忍受的强烈饥饿感，导致减重无法持续，容易崩盘！</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;前期先调整饮食结构，减少精致碳水摄入，增加蛋白质和膳食纤维的摄入，将精致碳水换成慢碳水（如红薯，玉米，杂粮饭等）</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;避免高糖和高加工食品，选择天然的、整个食物。足量蔬菜摄入，蔬菜富含纤维和营养素，有助于饱腹感。</view>
							</view>
						</view>
					</template>
					<template v-if="BMITip(BMI)=='超重'">
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;建议饮食摄入上不要有[过大]的热量差，以免出于难以忍受的强烈饥饿感，导致减重无法持续，容易崩盘！</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;前期先调整饮食结构，减少精致碳水摄入，增加蛋白质和膳食纤维的摄入，将精致碳水换成慢碳水（如红薯，玉米，杂粮饭等）</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;避免高糖和高加工食品，选择天然的、整个食物。足量蔬菜摄入，蔬菜富含纤维和营养素，有助于饱腹感。</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;控制饮食量，使用小型盘子，适量摄入，避免过量食用。</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;喝足够的水，有时候身体会将口渴误认为饥饿。</view>
							</view>
						</view>
					</template>
					<template v-if="BMITip(BMI)=='偏重'">
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;建议饮食摄入上不要有[过大]的热量差，以免出于难以忍受的强烈饥饿感，导致减重无法持续，容易崩盘！</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;前期先调整饮食结构，减少精致碳水摄入，增加蛋白质和膳食纤维的摄入，将精致碳水换成慢碳水（如红薯，玉米，杂粮饭等）</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;避免高糖和高加工食品，选择天然的、整个食物。足量蔬菜摄入，蔬菜富含纤维和营养素，有助于饱腹感。</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;控制饮食量，使用小型盘子，适量摄入，避免过量食用。</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;喝足够的水，有时候身体会将口渴误认为饥饿。</view>
							</view>
						</view>
					</template>
					<template v-if="BMITip(BMI)=='正常'">
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;均衡膳食： 确保摄入五大类食物，包括蔬菜、水果、全谷物、蛋白质和健康脂肪，以获取全面的营养。</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;适量食物： 控制食物摄入量，避免过度进食。听从身体的饥饱感，避免无谓的餐后零食。</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;多种蔬果： 增加蔬菜和水果的摄入，它们富含纤维、维生素和抗氧化剂。</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;选择健康蛋白： 选择瘦肉、鱼类、豆类和坚果，以获取优质蛋白质。</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;整全谷物： 选择全麦面包、糙米等全谷物，提供更多纤维和复杂碳水化合物。</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;健康脂肪： 选择橄榄油、鱼油等健康脂肪，限制饱和脂肪和反式脂肪。</view>
							</view>
						</view>
					</template>
					<template v-if="BMITip(BMI)=='偏瘦'">
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;高营养食物： 注重摄入高营养密度的食物，如坚果、种子、鱼类、蛋类、奶制品、豆类和全麦产品。</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;频繁小餐： 分多次进食，保证每天有足够的热量摄入，避免长时间空腹。</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;健康脂肪： 增加健康脂肪摄入，如橄榄油、鳄梨、坚果等，有助于提供额外的能量。</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;高蛋白质： 增加蛋白质摄入，选择瘦肉、鱼、豆腐、乳制品等富含优质蛋白的食物。</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;全谷物： 选择全谷物食品，如全麦面包、糙米，提供持久的能量。</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;维生素和矿物质补充： 如有需要，考虑添加多种维生素和矿物质的补充剂，但最好在医生建议下进行。</view>
							</view>
						</view>
					</template>
					
					<view class="data-info-motion">运动建议</view>
					<template v-if="BMITip(BMI)=='严重超重'">
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;不要做剧烈运动，因体重过大，剧烈运动（如跑步，踢球，羽毛球等）会损伤关节。</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;散步： 逐渐增加每天的步行距离，这是低冲击、易于实施的运动方式，有助于燃烧卡路里。</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;水中运动： 水中运动如游泳或水中有氧运动，能够减轻身体重量，对关节更加温和。</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;自行车骑行： 自行车骑行是低冲击的有氧运动，有助于提高心肺健康，减轻对关节的压力。</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;瑜伽： 适度的瑜伽练习有助于提高柔韧性、平衡和核心力量，对关节友好。</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;渐进性耐力训练： 使用轻负荷逐渐增加耐力训练，如举重，以提高代谢和增强肌肉。</view>
							</view>
						</view>
					</template>
					<template v-if="BMITip(BMI)=='超重'">
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;有氧运动： 包括步行、跑步、游泳等，有助于提高心肺健康和燃烧卡路里。</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;耐力训练： 进行轻中度的耐力训练，如举重，有助于增加肌肉质量，提高基础代谢率。</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;每天保持活动： 尽量每天保持一定的活动水平，例如步行、爬楼梯等</view>
							</view>
						</view>
					</template>
					<template v-if="BMITip(BMI)=='偏重'">
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;有氧运动： 包括步行、跑步、游泳等，有助于提高心肺健康和燃烧卡路里。</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;耐力训练： 进行轻中度的耐力训练，如举重，有助于增加肌肉质量，提高基础代谢率。</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;每天保持活动： 尽量每天保持一定的活动水平，例如步行、爬楼梯等</view>
							</view>
						</view>
					</template>
					<template v-if="BMITip(BMI)=='正常'">
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;有氧运动： 至少每周150分钟中等强度的有氧运动，如快走、跑步、游泳，有助于心血管健康。</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;耐力训练： 每周进行两次以上的耐力训练，如举重或其他力量训练，以促进肌肉强度和代谢。</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;伸展锻炼： 包括瑜伽、普拉提等，有助于提高柔韧性和维持身体平衡。</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;日常活动： 尽量保持日常活动，如步行、爬楼梯，以增加总体身体活动量。</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;锻炼计划： 制定持续可行的锻炼计划，确保活动量逐渐增加。</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;休息和恢复： 为身体提供足够的休息和恢复时间，以避免过度训练和减少受伤风险。</view>
							</view>
						</view>
					</template>
					<template v-if="BMITip(BMI)=='偏瘦'">
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;轻度有氧运动： 逐渐开始进行轻度的有氧运动，如步行、缓慢慢跑，以提高心肺健康。</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;轻柔耐力训练： 进行轻柔的耐力训练，使用较轻的重量，以增强肌肉质量。</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;瑜伽和伸展： 参与瑜伽和伸展活动，有助于提高柔韧性、平衡和身体姿势。</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;渐进性增加： 逐渐增加运动时间和强度，但要注意避免过度劳累。</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;定时休息： 为身体提供足够的休息和恢复时间，以促进肌肉生长和适应。</view>
							</view>
						</view>
						<view class="data-info-text">
							<view class="info-text-content">
								<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
								<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;专业指导： 在开始任何新的饮食和运动计划之前，请咨询医生或专业健康提供者的建议，确保安全性和适应性。</view>
							</view>
						</view>
					</template>
					<!--
					<view class="data-info-text">
						<view class="info-text-content">
							<image class="text-content-icon" src="@/static/image/icon-warn.png"></image>
							<view class="text-content-text">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;建议不要做剧烈的运动（如跑步，踢球，羽毛球等），当前体重过重，剧烈运动会损伤对应关节。</view>
						</view>
					</view>
					-->
				</view>
			</view>
			<view style="height: 40rpx;"></view>
		</scroll-view>
		<!--出生日期选择-->
		<datepicker ref="birthdayPopup" @onGetDate="onGetDate"></datepicker>
		<!--身高选择-->
		<height ref="heightPopup" @onGetHeight="onGetHeight" />
		<!--体重记录-->
		<weightRecord ref="weightRecordPopup" :initial-vlue="newWeight" @onCloseWeight="onCloseWeight"></weightRecord>
		<!--初始目标体重-->
		<weight ref="weightPopup" :title="weightPopupTitle" :initial-vlue="weightPopupWeight" @onGetWeight="onGetWeight"></weight>
		<!--热量差选择-->
		<calorie ref="caloriePopup" @onGetCalorie="onGetCalorie" />

        <statement ref="stPopup"></statement>
	</view>
</template>

<script setup lang="tsx" name="bodyData">
import { getBodyInfo,editUserHealth } from "@/api/api";
import { ref,nextTick } from "vue";
import { onShow,onLoad } from '@dcloudio/uni-app';
import { userData as userDataStore } from "@/store/userData";
import BigNumber from "bignumber.js";
import datepicker from "./components/datepicker.vue";
import height from "./components/height.vue";
import weightRecord from "./components/weightRecord.vue";
import weight from "./components/weight.vue";
import calorie from "./components/calorie.vue";
import moment from 'moment';
import statement from "@/components/statement.vue";
import { ver } from "@/store/ver";
const VER = ver();
const stPopup = ref(null);
const openSt = ()=>{
    stPopup.value.open();
}

const userData: any = userDataStore();
const bodyInfo:any = ref();
const goBack = () => {
	uni.navigateBack();
};



const schedule = ref(0);//减肥完成度
const complete = ref(0);//已减重量
const BMI = ref(0);//体质指数
const bodyfat = ref(0);//体脂率
const consumeRest = ref(0);//基础代谢
const isNormal = ref(true);//指数是否正常
const active = ref(false);

const openLink = (link: string) => {
            uni.navigateTo({
                url: `/pages/webview/webview?url=${encodeURI(link)}`,
            });
        };

onLoad((options:any)=>{
	if(options.type!=null&&options.type=='record'){
		loadShow();
	}
});
const loadShow = () => {
	setTimeout(function() {
		active.value = true
	}, 1000);
	setTimeout(function() {
		active.value = false
	}, 1700);
	setTimeout(function() {
		active.value = true
	}, 2400);
	setTimeout(function() {
		active.value = false
	}, 3100);
}
onShow(()=>{
	refreshData();
});
const refreshData = () => {
	getBodyInfo({userId:userData.id}).then((res:any) => {
		if(res.success){
			bodyInfo.value = res.data;
			//console.log(bodyInfo.value)
			//bodyInfo.value.userWeightRecord.weight = 70;
			
			let initWeight = bodyInfo.value?.userHealth?.initWeight;
			let aimWeight = bodyInfo.value?.userHealth?.aimWeight;
			let weight = bodyInfo.value?.userWeightRecord?.weight;
			let stature = bodyInfo.value?.userHealth?.stature;
			let age = bodyInfo.value?.userHealth?.age;
			let sex = bodyInfo.value?.userHealth?.sex;
			//计算减肥完成率
			if(initWeight!=null&&aimWeight!=null&&weight!=null){
				let aim = new BigNumber(initWeight).minus(new BigNumber(aimWeight));//目标减重
				complete.value = new BigNumber(initWeight).minus(new BigNumber(weight)).toNumber()//当前减重
				schedule.value = Math.round(new BigNumber(complete.value).div(aim).times(new BigNumber(100)).toNumber());
				if(schedule.value>100)schedule.value = 100;
				if(schedule.value<0)schedule.value = 0;
			}
			//计算体质指数
			if(stature!==null&&weight!=null){
				let m = new BigNumber(stature).div(new BigNumber(100));
				BMI.value = Number(new BigNumber(weight).div(m.times(m)).toNumber().toFixed(1));
			}
			//计算体脂
			if(BMI.value>0&&age!=null&&sex>0){
				let val = new BigNumber(1.2).times(new BigNumber(BMI.value)).plus(new BigNumber(0.23).times(new BigNumber(age))).minus(new BigNumber(5.4))
				if(sex==1){
					val.minus(new BigNumber(18.1))
				}
				bodyfat.value = Number(val.toNumber().toFixed(1));
				
			}
			//基础代谢计算
			if(stature!==null&&weight!=null&&sex>0){
				if (sex === 1) {
				    let weights = new BigNumber(13.73).multipliedBy(
						new BigNumber(weight)
				    );
				    let height = new BigNumber(5).multipliedBy(
						new BigNumber(stature)
				    );
				    let ages = new BigNumber(6.9).multipliedBy(
						new BigNumber(age)
					);
				    consumeRest.value = Math.round(
				        new BigNumber(67).plus(weights).plus(height).minus(ages).toNumber()
				    );
					//console.log(consumeRest.value)
				}
				if (sex === 2) {
				    let weights = new BigNumber(9.6).multipliedBy(
				        new BigNumber(weight)
				    );
				    let height = new BigNumber(1.72).multipliedBy(
				        new BigNumber(stature)
				    );
				    let ages = new BigNumber(4.7).multipliedBy(
						new BigNumber(age)
					);
				    consumeRest.value = Math.round(
				        new BigNumber(661).plus(weights).plus(height).minus(ages).toNumber()
				    );
				}
			}
			if(BMI.value>23.9||bodyfat.value>34.9){
				isNormal.value = false;
			}else{
				isNormal.value = true;
			}
			loseWeight();
		}
	});
}
const BMITip = (index:number) => {
	if(index<18.5)return "偏瘦";
	if(index>=18.5&&index<=23.9)return "正常";
	if(index>=24&&index<=29.9)return "偏重";
	if(index>=30&&index<=34.9)return "超重";
	if(index>34.9)return "严重超重";
}
const bodyfatTip = (index:number) => {
	if(index<20)return "偏瘦";
	if(index>=20&&index<=34.9)return "正常";
	if(index>=35&&index<=39.9)return "偏重";
	if(index>=40)return "超重";
}
//出生日期选择相关
const birthdayPopup = ref()
const showBirthdayPopup = () => {
	//传默认日期
	birthdayPopup.value.showPopup(bodyInfo.value?.userHealth?.birthday);
}
//出生日期修改
const onGetDate = (e: any) => {
	let params = {
		userId:userData.id,
		birthday:moment(e,"YYYY年MM月DD日").format('YYYY-MM-DD')
	}
	editUserHealth(params).then((res:any) => {
		if(res.success){
			refreshData();
		}
	});
}
//身高选择
const heightPopup = ref();
const showHeightPopup = () => {
	heightPopup.value.showPopup(bodyInfo.value?.userHealth?.stature);
}
const onGetHeight = (e: any) => {
	let params = {
		userId:userData.id,
		stature:e
	}
	editUserHealth(params).then((res:any) => {
		if(res.success){
			refreshData();
		}
	});
}
//体重记录
const weightRecordPopup = ref(); //体重控件
const newWeight = ref("");
const showWeightRecord = () => {
	let weight = bodyInfo.value?.userWeightRecord?.weight?.toString();
	if(weight==null||weight=='')weight = "60.0";
	if(weight.indexOf(".")===-1)weight+=".0";
	newWeight.value = weight;
	nextTick(() => {
		weightRecordPopup.value.open();
	});
};
const onCloseWeight = () => {
	refreshData();
}
//初始体重与目标体重修改
const weightPopup = ref();
const weightPopupTitle = ref();
const weightPopupWeight = ref();
const showEditIntiWeight = () => {
	weightPopupTitle.value = "修改初始体重";
	let weight = bodyInfo.value?.userHealth?.initWeight.toString();
	if(weight.indexOf(".")===-1)weight+=".0"
	weightPopupWeight.value = weight;
	nextTick(() => {
		weightPopup.value.open();
	});
	
}
const showEditAimWeight = () => {
	weightPopupTitle.value = "修改目标体重";
	let weight = bodyInfo.value?.userHealth?.aimWeight.toString();
	if(weight.indexOf(".")===-1)weight+=".0"
	weightPopupWeight.value = weight;
	nextTick(() => {
		weightPopup.value.open();
	});
	
}
const onGetWeight = (weight:number) => {
	//console.log(weight)
	let params = {
		userId:userData.id,
		initWeight:bodyInfo.value?.userHealth?.initWeight,
		aimWeight:bodyInfo.value?.userHealth?.aimWeight,
	}
	if(weightPopupTitle.value == "修改初始体重"){
		if(weight<=bodyInfo.value?.userHealth?.aimWeight){
			uni.showToast({
				title: "初始体重不可小于等于目标体重",
				icon: 'none',  
				duration: 1500,
			})
			return;
		}
		params.initWeight = weight;
	}
	if(weightPopupTitle.value == "修改目标体重"){
		if(weight>=bodyInfo.value?.userHealth?.initWeight){
			uni.showToast({
				title: "目标体重不可大于等于初始体重",
				icon: 'none',  
				duration: 1500,
			})
			return;
		}
		params.aimWeight = weight;
	}
	editUserHealth(params).then((res:any) => {
		if(res.success){
			uni.showToast({
			    title: res.message,  
			    icon: 'success',  
			    duration: 1500,
			});
			weightPopup.value.close();
			refreshData();
		}else{
			uni.showToast({
			    title: res.message,  
			    icon: 'none',  
			    duration: 1500,
			});
		}
	})
}

//计算减重信息
const describe = ref();
const loseWeight = () => {
	if(bodyInfo.value?.userHealth?.initWeight==null||bodyInfo.value?.userHealth?.aimWeight==null||bodyInfo.value?.userHealth?.heatIsPoor==null)return;
	let weight = parseFloat(bodyInfo.value?.userHealth?.initWeight);
	let aimWeight = parseFloat(bodyInfo.value?.userHealth?.aimWeight);
	let heatIsPoor = Number(bodyInfo.value?.userHealth?.heatIsPoor);
	console.log(bodyInfo.value)
	//如果初始重量小于等于目标重量则返回不做计算
	describe.value = "";
	if(weight<=aimWeight)return;
	let ratio = 7.7;//热量比率
	
	if(bodyInfo.value?.userWeightRecord!=null)weight = bodyInfo.value?.userWeightRecord?.weight;
	//每周减重千克数
	let weekly = parseFloat((((heatIsPoor + (bodyInfo.value?.rest*0.25))/ratio)/1000 * 7).toFixed(2));
	//预计完成天数
	let day = Math.ceil(((weight - aimWeight)/ weekly ) * 7) 
	
	if(heatIsPoor>=100&&heatIsPoor<=200){
		describe.value = "按此热量差，非常容易实现，减肥效果可能不明显，可保持目前体重。"
	}
	if(heatIsPoor>=201&&heatIsPoor<=350){
		describe.value = "按此热量差，容易实现，每周可减重" + weekly + "千克"
		if(day>0){
			describe.value+="，预计" + day + "天可达到目标体重。"
		}else{
			describe.value+="。"
		}
	}
	if(heatIsPoor>=351&&heatIsPoor<=500){
		describe.value = "按此热量差，有一定挑战，每周可减重" + weekly + "千克"
		if(day>0){
			describe.value+="，预计" + day + "天可达到目标体重。"
		}else{
			describe.value+="。"
		}
	}
	if(heatIsPoor>=501&&heatIsPoor<=700){
		describe.value = "按此热量差，有一定挑战，可能影响身体健康，每周可减重" + weekly + "千克。"
	}
	if(heatIsPoor>=701&&heatIsPoor<=1000){
		describe.value = "按此热量差，难度较大且影响身体健康，每周可减重" + weekly + "千克。"
	}
	if(heatIsPoor>=1001&&heatIsPoor<=1500){
		describe.value = "按此热量差，严重影响身体健康，不建议按此方案执行。"
	}
}
const goBodyDataDetails = () => {
	uni.navigateTo({
	    url: `/pages/bodyDataDetails/bodyDataDetails`,
	});
}
//热量差修改
const caloriePopup = ref();
const showCaloriePopup = () => {
	caloriePopup.value.showPopup(bodyInfo.value?.userHealth?.heatIsPoor);
}
const onGetCalorie = (e: any) => {
	let params = {
		userId:userData.id,
		heatIsPoor:e
	}
	editUserHealth(params).then((res:any) => {
		if(res.success){
			refreshData();
		}
	});
}
</script>
<style lang="scss" scoped>
@import './bodyData.scss';
.health_desp{
    width:710rpx;
    margin:0 auto;
    padding:20rpx;
    border-radius: 10rpx;
    background:#fff;
    margin-top:20rpx;
    .row{
        font-size:20rpx;
        color:#666;
        font-weight:400;
        margin-top:10rpx;
        .link{
            text-decoration:underline;
            color:#566c94;
        }
    }
}
</style>
